<?php
session_start();
//If your session isn't valid, it returns you to the login screen for protection
if(empty($_SESSION['myusername'])){
 header("location:main_login.php");
}
//echo $_SESSION['myusername'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link href="default.css" rel="stylesheet" type="text/css" />
        <title>Judges Management Panel</title>
</head>
<body>
<div id="fulladmin">

<?php
/* 
        admin.php
        Displays all data from 'players' table
*/

        // connect to the database
        include('connect-db.php');

        // get results from database
        $result = mysql_query("SELECT * FROM judges") 
                or die(mysql_error());  
                
        // display data in table
	    echo "<div id='adminleft'>";
        echo "<p><b>View All</b> | <a href='judge-paginated.php?page=1'>View Paginated</a></p>";
		echo "</div>";
        echo "<div id='adminright'>";
		echo "<center><h1>Referring Judges Management Panel</h1><br>";
        echo "<table border='1' cellpadding='10'>";
        echo "<tr><th>Id</th><th>Referring Judge </th> <th>Court Origin</th> <th></th> </tr>";

        // loop through results of database query, displaying them in the table
        while($row = mysql_fetch_array( $result )) {
                
                // echo out the contents of each row into a table
                echo "<tr>";
				echo '<td>' . $row['judgeId'] . '</td>';
                echo '<td>' . $row['referringJudge'] . '</td>';
                echo '<td>' . $row['courtOrigin'] . '</td>';
                echo '<td><strong><a href="editjudge.php?id=' . $row['judgeId'] . '">Edit</a></strong></td>';
				//echo '<td>';
				//echo '<strong><a href="deletejudge.php?id=' . $row['judgeId'] . '">Delete</a></strong>';
			    //echo "</td>";
                echo "</tr>"; 
        } 

        // close table>
        echo "</table>";
?>
<p><strong><a href="newjudge.php">>>Add Judge<<</a><strong></p></center>
</div>
</div>
<div id="footer"><center>Return to main <a href="dashboard.php"><font color="red">Dashboard</font></a>, or you can <a href="log_out.php?id=<?php echo $_SESSION['userid']; ?>"><font color="red">Log Out</font></a></center></div>

</body>
</html> 